﻿/**
 * 更新产品信息交易
 */

package org.ccams.tran;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.ccams.domain.TMateriel;
import org.ccams.util.StrHelper;
import java.math.BigDecimal;

public class Tran12133 extends AbstractJsonTran {

	@SuppressWarnings("unchecked")
	public void buildJSONObject(Map model, JSONObject json,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		Long idt_materiel = Long.parseLong(request.getParameter("idt_materiel"));
	    String materielno    =(String) request.getParameter("materielno");       
	    String materielname  =(String) request.getParameter("materielname");    
	    String materielclass =(String) request.getParameter("materielclass"); 
	    String spec          =(String) request.getParameter("spec"); 
	    String spellcode     =(String) request.getParameter("spellcode");
	    BigDecimal attrib1    = new BigDecimal(StrHelper.getDouble(request.getParameter("attrib1"),0)); 
	    String attribunit1   =(String) request.getParameter("attribunit1");      
	    BigDecimal attrib2    =  new BigDecimal(StrHelper.getDouble(request.getParameter("attrib2"),0));        
	    String attribunit2   =(String) request.getParameter("attribunit2");      
	    BigDecimal attrib3    =  new BigDecimal(StrHelper.getDouble(request.getParameter("attrib3"),0));          
	    String attribunit3   =(String) request.getParameter("attribunit3");      
	    BigDecimal attrib4    =  new BigDecimal(StrHelper.getDouble(request.getParameter("attrib4"),0));        
	    String attribunit4   =(String) request.getParameter("attribunit4");      
	    BigDecimal attrib5    =  new BigDecimal(StrHelper.getDouble(request.getParameter("attrib5"),0));      
	    String attribunit5   =(String) request.getParameter("attribunit5");         
	    String remark        =(String) request.getParameter("remark");
	    String goodsclass    = request.getParameter("goodsclass");
	    String prov_name	 = request.getParameter("prov_name");
	    System.out.println("物料大类  :   "+goodsclass);
	    TMateriel t = new TMateriel();
	    t.setIdt_materiel(idt_materiel);
		t.setMaterielno(materielno);
		t.setMaterielname(materielname);
		t.setMaterielclass(materielclass);
		t.setSpec(spec);
		t.setSpellcode(spellcode);
		t.setAttrib1(attrib1);
		t.setAttribunit1(attribunit1);
		t.setAttrib2(attrib2);
		t.setAttribunit2(attribunit2);
		t.setAttrib3(attrib3);
		t.setAttribunit3(attribunit3);
		t.setAttrib4(attrib4);
		t.setAttribunit4(attribunit4);
		t.setAttrib5(attrib5);
		t.setAttribunit5(attribunit5);
		t.setRemark(remark);
		t.setGoodsclass(goodsclass);
		t.setProv_name(prov_name);
		HashMap<String, Object> jsonMap = new HashMap<String, Object>();
		boolean success = false;
		String message = "";
		int i = getCcamsService().getTmaterielDao().updateTMateriel(t);
		if (i == 1) {
			success = true;
			message = "物料更新成功";
		} else {
			success = false;
			message = "物料更新失败";
		}
		jsonMap.put("success", success);
		jsonMap.put("message", message);
		json.putAll(jsonMap);
	}
}
